<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<jsp:directive.page import="entities.*"/>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>gerer les categories,suppimer,modifier</title>
<script language="JavaScript">
	function   aa()   { 
		var id = document.getElementsByName("id");
		var temp;
  		for   (var   i=0;i <id.length;i++)   { 
			if   (id[i].checked)   { 
				temp=id[i].value;
				} 
			}
  		return temp;
	} 
	function   modifier(){ 
		var newName=document.getElementById("nName").value;

		window.location.href="SevCategory?types=update&name="+newName+"&id="+aa();
	} 
	function supprimer(){
		window.location.href="SevCategory?types=del&id="+aa();
	}
	function add(){
		var newName=document.getElementById("nName").value;
		window.location.href="SevCategory?types=add&name="+newName;
	}

</script> 
</head>
<body>
	<% 
  		String message = (String)request.getAttribute("message")==null?"":(String)request.getAttribute("message");
  		if(!message.equals("")){
  	%>
  		<%=message %>
  	<%} %>
  	<P><tr>tous les categories</tr></P>
  	<table border="3">	
  	    <tr>
  	    	<td align="center">choisir le categories</td>
    		<td align="center">nom du Category</td>
    	</tr>
    <% 
    	List<Category> arrL=(List<Category>)request.getAttribute("allCate");
    	Iterator<Category> it=arrL.iterator();
    	while(it.hasNext()){
    		 Category tmCate= it.next();
    %>
    		<tr>
    			<td align="center"><input type="radio" name="id" value=<%=tmCate.getIdCategory()%> onclick="aa()" ></td>
    			<td align="center"><%=tmCate.getName() %></td>
    		</tr>
    <%}%>
    
    </table>
     <p>Name<input type="text" name="nouveau nome pour ce categorie" id="nName"></p>
      <input type="button" name="btnAdd" onclick="add()" value="Add votre categorie">
         <input type="button" name="btnModifier" onclick="modifier()" value="Modifier votre categorie">
     <input type="button" name="btnSupp" onclick="supprimer()" value="supprimer cette categorie">
    <form action="functionsAdmin.jsp" method="post">
    	<input type="submit" value="Back">
    </form>
</body>
</html>